#include"preCmpH.h"
#define WIN32_LEAN_AND_MEAN
#include<Windows.h>
#include"UIInputManager.h"

BEGIN_NAMESPACE(ui_manager)
BEGIN_NAMESPACE(ui_events)
BEGIN_NAMESPACE(ui_input)

UIInputManager::UIInputManager(){}
UIInputManager::~UIInputManager(){}
UIInputManager& UIInputManager::getInstance(){
	static UIInputManager* instance = null;
	if(instance == null)
	{
		instance = new UIInputManager();
	}
	return *instance;
}
void UIInputManager::ClearInput()
{
	ZeroMemory(&KeyboardInfo,sizeof(KeyboardInfo));
	ZeroMemory(&MouseInfo,sizeof(MouseInfo));
}
//-----------------------------------------------------------------------------
// Set KeyboardInfo
//-----------------------------------------------------------------------------
void UIInputManager::ResetKeys(){
	if(KeyboardInfo.key_LArrow == KEY_UP) { KeyboardInfo.key_LArrow = ACTION_NOACTION;}
	if(KeyboardInfo.key_RArrow == KEY_UP) { KeyboardInfo.key_RArrow = ACTION_NOACTION;}
	if(KeyboardInfo.key_UArrow == KEY_UP) { KeyboardInfo.key_UArrow = ACTION_NOACTION;}
	if(KeyboardInfo.key_DArrow == KEY_UP) { KeyboardInfo.key_DArrow = ACTION_NOACTION;}

	if(KeyboardInfo.key_Enter == KEY_UP) { KeyboardInfo.key_Enter = ACTION_NOACTION;}
	if(KeyboardInfo.key_Backspace == KEY_UP) { KeyboardInfo.key_Backspace = ACTION_NOACTION;}
	if(KeyboardInfo.key_Shift == KEY_UP) { KeyboardInfo.key_Shift = ACTION_NOACTION;}
	if(KeyboardInfo.key_Alt == KEY_UP) { KeyboardInfo.key_Alt = ACTION_NOACTION;}
	if(KeyboardInfo.key_Ctrl == KEY_UP) { KeyboardInfo.key_Ctrl = ACTION_NOACTION;}
	if(KeyboardInfo.key_Tab == KEY_UP) { KeyboardInfo.key_Tab = ACTION_NOACTION;}
		
	if(KeyboardInfo.key_F1 == KEY_UP) { KeyboardInfo.key_F1 = ACTION_NOACTION;}
	if(KeyboardInfo.key_F2 == KEY_UP) { KeyboardInfo.key_F2 = ACTION_NOACTION;}
	if(KeyboardInfo.key_F3 == KEY_UP) { KeyboardInfo.key_F3 = ACTION_NOACTION;}
	if(KeyboardInfo.key_F4 == KEY_UP) { KeyboardInfo.key_F4 = ACTION_NOACTION;}
	if(KeyboardInfo.key_F5 == KEY_UP) { KeyboardInfo.key_F5 = ACTION_NOACTION;}
	if(KeyboardInfo.key_F6 == KEY_UP) { KeyboardInfo.key_F6 = ACTION_NOACTION;}
	if(KeyboardInfo.key_F7 == KEY_UP) { KeyboardInfo.key_F7 = ACTION_NOACTION;}
	if(KeyboardInfo.key_F8 == KEY_UP) { KeyboardInfo.key_F8 = ACTION_NOACTION;}
	if(KeyboardInfo.key_F9 == KEY_UP) { KeyboardInfo.key_F9 = ACTION_NOACTION;}
	if(KeyboardInfo.key_F10 == KEY_UP) { KeyboardInfo.key_F10 = ACTION_NOACTION;}
	if(KeyboardInfo.key_F11 == KEY_UP) { KeyboardInfo.key_F11 = ACTION_NOACTION;}
	if(KeyboardInfo.key_F12 == KEY_UP) { KeyboardInfo.key_F12 = ACTION_NOACTION;}

	if(KeyboardInfo.key_0 == KEY_UP) { KeyboardInfo.key_0 = ACTION_NOACTION;}
	if(KeyboardInfo.key_1 == KEY_UP) { KeyboardInfo.key_1 = ACTION_NOACTION;}
	if(KeyboardInfo.key_2 == KEY_UP) { KeyboardInfo.key_2 = ACTION_NOACTION;}
	if(KeyboardInfo.key_3 == KEY_UP) { KeyboardInfo.key_3 = ACTION_NOACTION;}
	if(KeyboardInfo.key_4 == KEY_UP) { KeyboardInfo.key_4 = ACTION_NOACTION;}
	if(KeyboardInfo.key_5 == KEY_UP) { KeyboardInfo.key_5 = ACTION_NOACTION;}
	if(KeyboardInfo.key_6 == KEY_UP) { KeyboardInfo.key_6 = ACTION_NOACTION;}
	if(KeyboardInfo.key_7 == KEY_UP) { KeyboardInfo.key_7 = ACTION_NOACTION;}
	if(KeyboardInfo.key_8 == KEY_UP) { KeyboardInfo.key_8 = ACTION_NOACTION;}
	if(KeyboardInfo.key_9 == KEY_UP) { KeyboardInfo.key_9 = ACTION_NOACTION;}

	if(KeyboardInfo.key_A == KEY_UP) { KeyboardInfo.key_A = ACTION_NOACTION;}
	if(KeyboardInfo.key_B == KEY_UP) { KeyboardInfo.key_B = ACTION_NOACTION;}
	if(KeyboardInfo.key_C == KEY_UP) { KeyboardInfo.key_C = ACTION_NOACTION;}
	if(KeyboardInfo.key_D == KEY_UP) { KeyboardInfo.key_D = ACTION_NOACTION;}
	if(KeyboardInfo.key_E == KEY_UP) { KeyboardInfo.key_E = ACTION_NOACTION;}
	if(KeyboardInfo.key_F == KEY_UP) { KeyboardInfo.key_F = ACTION_NOACTION;}
	if(KeyboardInfo.key_G == KEY_UP) { KeyboardInfo.key_G = ACTION_NOACTION;}
	if(KeyboardInfo.key_H == KEY_UP) { KeyboardInfo.key_H = ACTION_NOACTION;}
	if(KeyboardInfo.key_I == KEY_UP) { KeyboardInfo.key_I = ACTION_NOACTION;}
	if(KeyboardInfo.key_J == KEY_UP) { KeyboardInfo.key_J = ACTION_NOACTION;}
	if(KeyboardInfo.key_K == KEY_UP) { KeyboardInfo.key_K = ACTION_NOACTION;}
	if(KeyboardInfo.key_L == KEY_UP) { KeyboardInfo.key_L = ACTION_NOACTION;}
	if(KeyboardInfo.key_M == KEY_UP) { KeyboardInfo.key_M = ACTION_NOACTION;}
	if(KeyboardInfo.key_N == KEY_UP) { KeyboardInfo.key_N = ACTION_NOACTION;}
	if(KeyboardInfo.key_O == KEY_UP) { KeyboardInfo.key_O = ACTION_NOACTION;}
	if(KeyboardInfo.key_P == KEY_UP) { KeyboardInfo.key_P = ACTION_NOACTION;}
	if(KeyboardInfo.key_Q == KEY_UP) { KeyboardInfo.key_Q = ACTION_NOACTION;}
	if(KeyboardInfo.key_R == KEY_UP) { KeyboardInfo.key_R = ACTION_NOACTION;}
	if(KeyboardInfo.key_S == KEY_UP) { KeyboardInfo.key_S = ACTION_NOACTION;}
	if(KeyboardInfo.key_T == KEY_UP) { KeyboardInfo.key_T = ACTION_NOACTION;}
	if(KeyboardInfo.key_U == KEY_UP) { KeyboardInfo.key_U = ACTION_NOACTION;}
	if(KeyboardInfo.key_V == KEY_UP) { KeyboardInfo.key_V = ACTION_NOACTION;}
	if(KeyboardInfo.key_W == KEY_UP) { KeyboardInfo.key_W = ACTION_NOACTION;}
	if(KeyboardInfo.key_X == KEY_UP) { KeyboardInfo.key_X = ACTION_NOACTION;}
	if(KeyboardInfo.key_Y == KEY_UP) { KeyboardInfo.key_Y = ACTION_NOACTION;}
	if(KeyboardInfo.key_Z == KEY_UP) { KeyboardInfo.key_Z = ACTION_NOACTION;}
}
void UIInputManager::SetKeyState(unsigned short key, unsigned short action){
	if(!keyboard_prev_set){
		KeyboardInfo.prev_action_key = key;
		KeyboardInfo.prev_action_type = action;
		keyboard_prev_set = true;
	} else {
		keyboard_prev_set = false;
	}
	switch(action)
	{
	case ACTION_NOACTION:
		_setKnoaction(key);
		break;
	case KEY_DOWN:
		_setKdown(key);
		break;
	case KEY_UP:
		_setKup(key);
		break;
	}
	KeyboardInfo.last_action_key = key;
	KeyboardInfo.last_action_type = action;
}
void UIInputManager::SetKeysStateChanged(bool changed){
	keyboard_state_changed = changed;
}
//-----------------------------------------------------------------------------
// Set MouseInfo
//-----------------------------------------------------------------------------
void UIInputManager::ResetButtons()
{
	if( MouseInfo.LButton = ACTION_UP) { MouseInfo.LButton = ACTION_NOACTION; }
	if( MouseInfo.RButton = ACTION_UP) { MouseInfo.RButton = ACTION_NOACTION; }
	if( MouseInfo.MButton = ACTION_UP) { MouseInfo.MButton = ACTION_NOACTION; }
}
void UIInputManager::SetMouseButtonState(unsigned short button, unsigned short action){
	if(!mouse_prev_set){
		MouseInfo.prev_action_button = button;
		MouseInfo.prev_action_type = action;
		mouse_prev_set = true;
	} else {
		mouse_prev_set = false;
	}
	switch(action)
	{
	case ACTION_NOACTION:
		_setBnoaction(button);
		break;
	case ACTION_DOWN:
		_setBdown(button);
		break;
	case ACTION_UP:
		_setBup(button);
		break;
	}
	MouseInfo.last_action_button = button;
	MouseInfo.last_action_type = action;
}
void UIInputManager::SetMouseCoordX(int x)
{
	MouseInfo.X += x;
}
void UIInputManager::SetMouseCoordY(int y)
{
	MouseInfo.Y += y;
}
void UIInputManager::SetMouseCoordXY(int x,int y)
{
	SetMouseCoordX(x);
	SetMouseCoordY(y);
}
void UIInputManager::SetMouseAbsCoordX(int x)
{
	MouseInfo.AX = x;
}
void UIInputManager::SetMouseAbsCoordY(int y)
{
	MouseInfo.AY = y;
}
void UIInputManager::SetMouseAbsCoordXY(int x,int y)
{
	SetMouseAbsCoordX(x);
	SetMouseAbsCoordY(y);
}
void UIInputManager::SetButtonsStateChanged(bool changed){
	mouse_state_changed = changed;
}
//-----------------------------------------------------------------------------
// Get KeyboardInfo
//-----------------------------------------------------------------------------
short UIInputManager::GetPrevKeyAction(){
	return KeyboardInfo.prev_action_type;
}
short UIInputManager::GetPrevKey(){
	return KeyboardInfo.prev_action_key;
}
short UIInputManager::GetLastKeyAction(){
	return KeyboardInfo.last_action_type;
}
short UIInputManager::GetLastKey(){
	return KeyboardInfo.last_action_key;
}
short UIInputManager::GetKeyState(unsigned short key)
{
	switch(key)
	{
	case KEY_LEFT: return KeyboardInfo.key_LArrow;
	case KEY_RIGHT:return KeyboardInfo.key_RArrow;
	case KEY_UP:return  KeyboardInfo.key_UArrow;
	case KEY_DOWN:return  KeyboardInfo.key_DArrow;
		 
	case KEY_RETURN:return  KeyboardInfo.key_Enter;
	case KEY_BACKSPACE:return  KeyboardInfo.key_Backspace;
	case KEY_SHIFT:return  KeyboardInfo.key_Shift;
	case KEY_ALT: return KeyboardInfo.key_Alt;
	case KEY_CTRL: return KeyboardInfo.key_Ctrl;
	case KEY_TAB: return KeyboardInfo.key_Tab;

	case KEY_F1: return KeyboardInfo.key_F1;
	case KEY_F2: return KeyboardInfo.key_F2;
	case KEY_F3: return KeyboardInfo.key_F3;
	case KEY_F4: return KeyboardInfo.key_F4;
	case KEY_F5: return KeyboardInfo.key_F5;
	case KEY_F6: return KeyboardInfo.key_F6;
	case KEY_F7: return KeyboardInfo.key_F7;
	case KEY_F8: return KeyboardInfo.key_F8;
	case KEY_F9: return KeyboardInfo.key_F9;
	case KEY_F10: return KeyboardInfo.key_F10;
	case KEY_F11: return KeyboardInfo.key_F11;
	case KEY_F12: return KeyboardInfo.key_F12;

	case '0': return KeyboardInfo.key_0;
	case '1': return KeyboardInfo.key_1;
	case '2': return KeyboardInfo.key_2;
	case '3': return KeyboardInfo.key_3;
	case '4': return KeyboardInfo.key_4;
	case '5': return KeyboardInfo.key_5;
	case '6': return KeyboardInfo.key_6;
	case '7': return KeyboardInfo.key_7;
	case '8': return KeyboardInfo.key_8;
	case '9': return KeyboardInfo.key_9;
	
	case 'A': return KeyboardInfo.key_A;
	case 'B': return KeyboardInfo.key_B;
	case 'C': return KeyboardInfo.key_C;
	case 'D': return KeyboardInfo.key_D;
	case 'E': return KeyboardInfo.key_E;
	case 'F': return KeyboardInfo.key_F;
	case 'G': return KeyboardInfo.key_G;
	case 'H': return KeyboardInfo.key_H;
	case 'I': return KeyboardInfo.key_I;
	case 'J': return KeyboardInfo.key_J;
	case 'K': return KeyboardInfo.key_K;
	case 'L': return KeyboardInfo.key_L;
	case 'M': return KeyboardInfo.key_M;
	case 'N': return KeyboardInfo.key_N;
	case 'O': return KeyboardInfo.key_O;
	case 'P': return KeyboardInfo.key_P;
	case 'Q': return KeyboardInfo.key_Q;
	case 'R': return KeyboardInfo.key_R;
	case 'S': return KeyboardInfo.key_S;
	case 'T': return KeyboardInfo.key_T;
	case 'U': return KeyboardInfo.key_U;
	case 'V': return KeyboardInfo.key_V;
	case 'W': return KeyboardInfo.key_W;
	case 'X': return KeyboardInfo.key_X;
	case 'Y': return KeyboardInfo.key_Y;
	case 'Z': return KeyboardInfo.key_Z;
	default: return -1;
	}
}
//keysStruct* UIInputManager::GetKeyboardKeyboardInfo()
//{
//	return &KeyboardInfo;
//}
bool UIInputManager::hasKeysStateChanged(){
	return keyboard_state_changed;
}
//-----------------------------------------------------------------------------
// Get MouseInfo
//-----------------------------------------------------------------------------
short UIInputManager::GetPrevMouseAction(){
	return MouseInfo.prev_action_type;
}
short UIInputManager::GetPrevMouseButton(){
	return MouseInfo.prev_action_button;
}
short UIInputManager::GetLastMouseAction(){
	return MouseInfo.last_action_type;
}
short UIInputManager::GetLastMouseButton(){
	return MouseInfo.last_action_button;
}
short UIInputManager::GetMouseButtonState(unsigned short button)
{
	switch(button)
	{
	case BUTTON_LEFT:  return MouseInfo.LButton;
	case BUTTON_RIGHT: return MouseInfo.RButton;
	case BUTTON_MIDDLE:return MouseInfo.MButton;
	default: return -1;
	}
}
int UIInputManager::GetMouseCoordX()
{
	int n = MouseInfo.X;
	MouseInfo.X = 0;
	return n;
}
int UIInputManager::GetMouseCoordY()
{
	int n = MouseInfo.Y;
	MouseInfo.Y = 0;
	return n;
}
void UIInputManager::GetMouseCoordXY(int& x,int& y)
{
	x = MouseInfo.X;
	y = MouseInfo.Y;
}
int UIInputManager::GetMouseAbsCoordX()
{
	return MouseInfo.AX;
}
int UIInputManager::GetMouseAbsCoordY()
{
	return MouseInfo.AY;
}
void UIInputManager::GetMouseAbsCoordXY(int& x,int& y)
{
	x = MouseInfo.AX;
	y = MouseInfo.AY;
}
//mouseStruct* GetMouseInfo()
//{
//	return &MouseInfo;
//}
bool UIInputManager::hasButtonsStateChanged(){
	return mouse_state_changed;
}

// private
int GetMappedVirtualKey(int VK){
	switch (VK)
	{
	case VK_LEFT: return KEY_LEFT;
	case VK_RIGHT:return KEY_RIGHT;
	case VK_UP: return KEY_UP;
	case VK_DOWN: return KEY_DOWN;

	case VK_RETURN: return KEY_RETURN;
	case VK_BACK: return KEY_BACKSPACE;
	case VK_SHIFT: return KEY_SHIFT;
	case VK_MENU: return KEY_ALT;
	case VK_CONTROL: return KEY_CTRL;
	case VK_TAB: return KEY_TAB;
	case VK_SPACE: return KEY_SPACE;

	case VK_F1: return KEY_F1;
	case VK_F2: return KEY_F2;
	case VK_F3: return KEY_F3;
	case VK_F4: return KEY_F4;
	case VK_F5: return KEY_F5;
	case VK_F6: return KEY_F6;
	case VK_F7: return KEY_F7;
	case VK_F8: return KEY_F8;
	case VK_F9: return KEY_F9;
	case VK_F10: return KEY_F10;
	case VK_F11: return KEY_F11;
	case VK_F12: return KEY_F12;
	default: return VK;
	}
}
void UIInputManager::_setBnoaction(short button){
	switch (button)
	{
	case BUTTON_LEFT: MouseInfo.LButton = ACTION_NOACTION; return;
	case BUTTON_RIGHT: MouseInfo.RButton = ACTION_NOACTION; return;
	case BUTTON_MIDDLE: MouseInfo.MButton = ACTION_NOACTION; return;
	}
}
void UIInputManager::_setBdown(short button){
	switch (button)
	{
	case BUTTON_LEFT: MouseInfo.LButton = ACTION_DOWN; return;
	case BUTTON_RIGHT: MouseInfo.RButton = ACTION_DOWN; return;
	case BUTTON_MIDDLE: MouseInfo.MButton = ACTION_DOWN; return;
	}
}
void UIInputManager::_setBup(short button){
	switch (button)
	{
	case BUTTON_LEFT: MouseInfo.LButton = ACTION_UP; return;
	case BUTTON_RIGHT: MouseInfo.RButton = ACTION_UP; return;
	case BUTTON_MIDDLE: MouseInfo.MButton = ACTION_UP; return;
	}
}

void UIInputManager::_setKnoaction(short key){
	switch(key){
	case KEY_LEFT: KeyboardInfo.key_LArrow = ACTION_NOACTION; return;
	case KEY_RIGHT:KeyboardInfo.key_RArrow = ACTION_NOACTION; return;
	case KEY_UP: KeyboardInfo.key_UArrow = ACTION_NOACTION; return;
	case KEY_DOWN: KeyboardInfo.key_DArrow = ACTION_NOACTION; return;

	case KEY_RETURN: KeyboardInfo.key_Enter = ACTION_NOACTION; return;
	case KEY_BACKSPACE: KeyboardInfo.key_Backspace = ACTION_NOACTION; return;
	case KEY_SHIFT: KeyboardInfo.key_Shift = ACTION_NOACTION; return;
	case KEY_ALT: KeyboardInfo.key_Alt = ACTION_NOACTION; return;
	case KEY_CTRL: KeyboardInfo.key_Ctrl = ACTION_NOACTION; return;
	case KEY_TAB: KeyboardInfo.key_Tab = ACTION_NOACTION; return;

	case KEY_F1: KeyboardInfo.key_F1 = ACTION_NOACTION; return;
	case KEY_F2: KeyboardInfo.key_F2 = ACTION_NOACTION; return;
	case KEY_F3: KeyboardInfo.key_F3 = ACTION_NOACTION; return;
	case KEY_F4: KeyboardInfo.key_F4 = ACTION_NOACTION; return;
	case KEY_F5: KeyboardInfo.key_F5 = ACTION_NOACTION; return;
	case KEY_F6: KeyboardInfo.key_F6 = ACTION_NOACTION; return;
	case KEY_F7: KeyboardInfo.key_F7 = ACTION_NOACTION; return;
	case KEY_F8: KeyboardInfo.key_F8 = ACTION_NOACTION; return;
	case KEY_F9: KeyboardInfo.key_F9 = ACTION_NOACTION; return;
	case KEY_F10: KeyboardInfo.key_F10 = ACTION_NOACTION; return;
	case KEY_F11: KeyboardInfo.key_F11 = ACTION_NOACTION; return;
	case KEY_F12: KeyboardInfo.key_F12 = ACTION_NOACTION; return;

	case '0': KeyboardInfo.key_0 = ACTION_NOACTION; return;
	case '1': KeyboardInfo.key_1 = ACTION_NOACTION; return;
	case '2': KeyboardInfo.key_2 = ACTION_NOACTION; return;
	case '3': KeyboardInfo.key_3 = ACTION_NOACTION; return;
	case '4': KeyboardInfo.key_4 = ACTION_NOACTION; return;
	case '5': KeyboardInfo.key_5 = ACTION_NOACTION; return;
	case '6': KeyboardInfo.key_6 = ACTION_NOACTION; return;
	case '7': KeyboardInfo.key_7 = ACTION_NOACTION; return;
	case '8': KeyboardInfo.key_8 = ACTION_NOACTION; return;
	case '9': KeyboardInfo.key_9 = ACTION_NOACTION; return;
	
	case 'A': KeyboardInfo.key_A = ACTION_NOACTION; return;
	case 'B': KeyboardInfo.key_B = ACTION_NOACTION; return;
	case 'C': KeyboardInfo.key_C = ACTION_NOACTION; return;
	case 'D': KeyboardInfo.key_D = ACTION_NOACTION; return;
	case 'E': KeyboardInfo.key_E = ACTION_NOACTION; return;
	case 'F': KeyboardInfo.key_F = ACTION_NOACTION; return;
	case 'G': KeyboardInfo.key_G = ACTION_NOACTION; return;
	case 'H': KeyboardInfo.key_H = ACTION_NOACTION; return;
	case 'I': KeyboardInfo.key_I = ACTION_NOACTION; return;
	case 'J': KeyboardInfo.key_J = ACTION_NOACTION; return;
	case 'K': KeyboardInfo.key_K = ACTION_NOACTION; return;
	case 'L': KeyboardInfo.key_L = ACTION_NOACTION; return;
	case 'M': KeyboardInfo.key_M = ACTION_NOACTION; return;
	case 'N': KeyboardInfo.key_N = ACTION_NOACTION; return;
	case 'O': KeyboardInfo.key_O = ACTION_NOACTION; return;
	case 'P': KeyboardInfo.key_P = ACTION_NOACTION; return;
	case 'Q': KeyboardInfo.key_Q = ACTION_NOACTION; return;
	case 'R': KeyboardInfo.key_R = ACTION_NOACTION; return;
	case 'S': KeyboardInfo.key_S = ACTION_NOACTION; return;
	case 'T': KeyboardInfo.key_T = ACTION_NOACTION; return;
	case 'U': KeyboardInfo.key_U = ACTION_NOACTION; return;
	case 'V': KeyboardInfo.key_V = ACTION_NOACTION; return;
	case 'W': KeyboardInfo.key_W = ACTION_NOACTION; return;
	case 'X': KeyboardInfo.key_X = ACTION_NOACTION; return;
	case 'Y': KeyboardInfo.key_Y = ACTION_NOACTION; return;
	case 'Z': KeyboardInfo.key_Z = ACTION_NOACTION; return;
	}
}
void UIInputManager::_setKdown(short key){
	switch(key){
	case KEY_LEFT: KeyboardInfo.key_LArrow = ACTION_DOWN; return;
	case KEY_RIGHT:KeyboardInfo.key_RArrow = ACTION_DOWN; return;
	case KEY_UP: KeyboardInfo.key_UArrow = ACTION_DOWN; return;
	case KEY_DOWN: KeyboardInfo.key_DArrow = ACTION_DOWN; return;

	case KEY_RETURN: KeyboardInfo.key_Enter = ACTION_DOWN; return;
	case KEY_BACKSPACE: KeyboardInfo.key_Backspace = ACTION_DOWN; return;
	case KEY_SHIFT: KeyboardInfo.key_Shift = ACTION_DOWN; return;
	case KEY_ALT: KeyboardInfo.key_Alt = ACTION_DOWN; return;
	case KEY_CTRL: KeyboardInfo.key_Ctrl = ACTION_DOWN; return;
	case KEY_TAB: KeyboardInfo.key_Tab = ACTION_DOWN; return;

	case KEY_F1: KeyboardInfo.key_F1 = ACTION_DOWN; return;
	case KEY_F2: KeyboardInfo.key_F2 = ACTION_DOWN; return;
	case KEY_F3: KeyboardInfo.key_F3 = ACTION_DOWN; return;
	case KEY_F4: KeyboardInfo.key_F4 = ACTION_DOWN; return;
	case KEY_F5: KeyboardInfo.key_F5 = ACTION_DOWN; return;
	case KEY_F6: KeyboardInfo.key_F6 = ACTION_DOWN; return;
	case KEY_F7: KeyboardInfo.key_F7 = ACTION_DOWN; return;
	case KEY_F8: KeyboardInfo.key_F8 = ACTION_DOWN; return;
	case KEY_F9: KeyboardInfo.key_F9 = ACTION_DOWN; return;
	case KEY_F10: KeyboardInfo.key_F10 = ACTION_DOWN; return;
	case KEY_F11: KeyboardInfo.key_F11 = ACTION_DOWN; return;
	case KEY_F12: KeyboardInfo.key_F12 = ACTION_DOWN; return;

	case '0': KeyboardInfo.key_0 = ACTION_DOWN; return;
	case '1': KeyboardInfo.key_1 = ACTION_DOWN; return;
	case '2': KeyboardInfo.key_2 = ACTION_DOWN; return;
	case '3': KeyboardInfo.key_3 = ACTION_DOWN; return;
	case '4': KeyboardInfo.key_4 = ACTION_DOWN; return;
	case '5': KeyboardInfo.key_5 = ACTION_DOWN; return;
	case '6': KeyboardInfo.key_6 = ACTION_DOWN; return;
	case '7': KeyboardInfo.key_7 = ACTION_DOWN; return;
	case '8': KeyboardInfo.key_8 = ACTION_DOWN; return;
	case '9': KeyboardInfo.key_9 = ACTION_DOWN; return;
	
	case 'A': KeyboardInfo.key_A = ACTION_DOWN; return;
	case 'B': KeyboardInfo.key_B = ACTION_DOWN; return;
	case 'C': KeyboardInfo.key_C = ACTION_DOWN; return;
	case 'D': KeyboardInfo.key_D = ACTION_DOWN; return;
	case 'E': KeyboardInfo.key_E = ACTION_DOWN; return;
	case 'F': KeyboardInfo.key_F = ACTION_DOWN; return;
	case 'G': KeyboardInfo.key_G = ACTION_DOWN; return;
	case 'H': KeyboardInfo.key_H = ACTION_DOWN; return;
	case 'I': KeyboardInfo.key_I = ACTION_DOWN; return;
	case 'J': KeyboardInfo.key_J = ACTION_DOWN; return;
	case 'K': KeyboardInfo.key_K = ACTION_DOWN; return;
	case 'L': KeyboardInfo.key_L = ACTION_DOWN; return;
	case 'M': KeyboardInfo.key_M = ACTION_DOWN; return;
	case 'N': KeyboardInfo.key_N = ACTION_DOWN; return;
	case 'O': KeyboardInfo.key_O = ACTION_DOWN; return;
	case 'P': KeyboardInfo.key_P = ACTION_DOWN; return;
	case 'Q': KeyboardInfo.key_Q = ACTION_DOWN; return;
	case 'R': KeyboardInfo.key_R = ACTION_DOWN; return;
	case 'S': KeyboardInfo.key_S = ACTION_DOWN; return;
	case 'T': KeyboardInfo.key_T = ACTION_DOWN; return;
	case 'U': KeyboardInfo.key_U = ACTION_DOWN; return;
	case 'V': KeyboardInfo.key_V = ACTION_DOWN; return;
	case 'W': KeyboardInfo.key_W = ACTION_DOWN; return;
	case 'X': KeyboardInfo.key_X = ACTION_DOWN; return;
	case 'Y': KeyboardInfo.key_Y = ACTION_DOWN; return;
	case 'Z': KeyboardInfo.key_Z = ACTION_DOWN; return;
	}
}
void UIInputManager::_setKup(short key){
	switch(key){
	case KEY_LEFT: KeyboardInfo.key_LArrow = ACTION_UP; return;
	case KEY_RIGHT:KeyboardInfo.key_RArrow = ACTION_UP; return;
	case KEY_UP: KeyboardInfo.key_UArrow = ACTION_UP; return;
	case KEY_DOWN: KeyboardInfo.key_DArrow = ACTION_UP; return;

	case KEY_RETURN: KeyboardInfo.key_Enter = ACTION_UP; return;
	case KEY_BACKSPACE: KeyboardInfo.key_Backspace = ACTION_UP; return;
	case KEY_SHIFT: KeyboardInfo.key_Shift = ACTION_UP; return;
	case KEY_ALT: KeyboardInfo.key_Alt = ACTION_UP; return;
	case KEY_CTRL: KeyboardInfo.key_Ctrl = ACTION_UP; return;
	case KEY_TAB: KeyboardInfo.key_Tab = ACTION_UP; return;

	case KEY_F1: KeyboardInfo.key_F1 = ACTION_UP; return;
	case KEY_F2: KeyboardInfo.key_F2 = ACTION_UP; return;
	case KEY_F3: KeyboardInfo.key_F3 = ACTION_UP; return;
	case KEY_F4: KeyboardInfo.key_F4 = ACTION_UP; return;
	case KEY_F5: KeyboardInfo.key_F5 = ACTION_UP; return;
	case KEY_F6: KeyboardInfo.key_F6 = ACTION_UP; return;
	case KEY_F7: KeyboardInfo.key_F7 = ACTION_UP; return;
	case KEY_F8: KeyboardInfo.key_F8 = ACTION_UP; return;
	case KEY_F9: KeyboardInfo.key_F9 = ACTION_UP; return;
	case KEY_F10: KeyboardInfo.key_F10 = ACTION_UP; return;
	case KEY_F11: KeyboardInfo.key_F11 = ACTION_UP; return;
	case KEY_F12: KeyboardInfo.key_F12 = ACTION_UP; return;

	case '0': KeyboardInfo.key_0 = ACTION_UP; return;
	case '1': KeyboardInfo.key_1 = ACTION_UP; return;
	case '2': KeyboardInfo.key_2 = ACTION_UP; return;
	case '3': KeyboardInfo.key_3 = ACTION_UP; return;
	case '4': KeyboardInfo.key_4 = ACTION_UP; return;
	case '5': KeyboardInfo.key_5 = ACTION_UP; return;
	case '6': KeyboardInfo.key_6 = ACTION_UP; return;
	case '7': KeyboardInfo.key_7 = ACTION_UP; return;
	case '8': KeyboardInfo.key_8 = ACTION_UP; return;
	case '9': KeyboardInfo.key_9 = ACTION_UP; return;
	
	case 'A': KeyboardInfo.key_A = ACTION_UP; return;
	case 'B': KeyboardInfo.key_B = ACTION_UP; return;
	case 'C': KeyboardInfo.key_C = ACTION_UP; return;
	case 'D': KeyboardInfo.key_D = ACTION_UP; return;
	case 'E': KeyboardInfo.key_E = ACTION_UP; return;
	case 'F': KeyboardInfo.key_F = ACTION_UP; return;
	case 'G': KeyboardInfo.key_G = ACTION_UP; return;
	case 'H': KeyboardInfo.key_H = ACTION_UP; return;
	case 'I': KeyboardInfo.key_I = ACTION_UP; return;
	case 'J': KeyboardInfo.key_J = ACTION_UP; return;
	case 'K': KeyboardInfo.key_K = ACTION_UP; return;
	case 'L': KeyboardInfo.key_L = ACTION_UP; return;
	case 'M': KeyboardInfo.key_M = ACTION_UP; return;
	case 'N': KeyboardInfo.key_N = ACTION_UP; return;
	case 'O': KeyboardInfo.key_O = ACTION_UP; return;
	case 'P': KeyboardInfo.key_P = ACTION_UP; return;
	case 'Q': KeyboardInfo.key_Q = ACTION_UP; return;
	case 'R': KeyboardInfo.key_R = ACTION_UP; return;
	case 'S': KeyboardInfo.key_S = ACTION_UP; return;
	case 'T': KeyboardInfo.key_T = ACTION_UP; return;
	case 'U': KeyboardInfo.key_U = ACTION_UP; return;
	case 'V': KeyboardInfo.key_V = ACTION_UP; return;
	case 'W': KeyboardInfo.key_W = ACTION_UP; return;
	case 'X': KeyboardInfo.key_X = ACTION_UP; return;
	case 'Y': KeyboardInfo.key_Y = ACTION_UP; return;
	case 'Z': KeyboardInfo.key_Z = ACTION_UP; return;
	}
}

void UIInputManager::StartUp( UIEventManager& manager )
{
	keyboard_state_changed = false;
	mouse_state_changed = false;
	keyboard_prev_set = true;
	mouse_prev_set = true;
	ZeroMemory(&KeyboardInfo,sizeof(KeyboardInfo));
	ZeroMemory(&MouseInfo,sizeof(MouseInfo));
}

void UIInputManager::ShutDown()
{

}

END_NAMESPACE // UI inputs
END_NAMESPACE // UI events
END_NAMESPACE // UI manager